package com.miaosha.ms_03.service;

import com.miaosha.ms_03.dao.GoodsDao;
import com.miaosha.ms_03.domain.Goods;
import com.miaosha.ms_03.exception.GlobalException;
import com.miaosha.ms_03.result.CodeMsg;
import com.miaosha.ms_03.vo.GoodsVo;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;

/**
 * @Description //TODO
 * @Author Administrator
 * @DATE 2020/9/19 15:31
 **/
@Service
public class GoodsService {

    @Resource
    private GoodsDao goodsDao;

    public List<GoodsVo> listGoodsVo() {
        return goodsDao.listGoodsVoList();
    }

    public GoodsVo getGoodsById(Long goodsId) {
        if (goodsId == null) {
            throw new GlobalException(CodeMsg.fillParamEmptyArgs("商品ID"));
        }
        return goodsDao.getGoodsById(goodsId);
    }

    public Integer updateStock(Goods goods) {
        if (goods == null) {
            throw new GlobalException(CodeMsg.fillParamEmptyArgs("商品信息"));
        }
        return goodsDao.updateStock(goods);
    }
}
